import 'package:flutter/material.dart';
import 'package:twopaiflutter/seoondpage.dart';

class RoutePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new _RoutePageState();
  }
}

class _RoutePageState extends State<RoutePage> {
  List<String> list;

  @override
  void initState() {
    list = new List.from({
      "pushReplacementNamed",
      "push",
      "pushReplacement",
      "pushNamed",
      "pushAndRemoveUntil",
      "pushNamedAndRemoveUntil",
      "popAndPushNamed"
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        centerTitle: true,
        title: new Text("RoutePage"),
      ),
      body: new Center(
        child: new ListView.builder(
          itemCount: list.length,
          itemBuilder: (BuildContext context, int index) {
            return new Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                new MaterialButton(
                  onPressed:(){
                    Navigator.of(context).pushReplacementNamed("_SecondPageSate",).then((value) {});
                  },
                  child: new Text(list[index]),
                ),
                new Container(
                  width: double.infinity,
                  height: 1,
                  color: Colors.blue,
                  child: new Padding(padding: new EdgeInsets.fromLTRB(0, 1, 0, 0)),
                )
              ],
            );
          },
        ),
      ),
    );
  }

  _go(int index) {
    setState(() {
      switch (index) {
        case 0:
          Navigator.of(context).pushReplacementNamed("/pushReplacementNamedPage",).then((value) {});
          break;
        case 1:
          Navigator.of(context).push(new MaterialPageRoute(builder: (_) {
            new SecondPage("push");
          }));
          break;
//      case 2:
//        Navigator.of(context).pushReplacement(newRoute)
//        break;
//      case 3:
//        Navigator.of(context).pushNamed(routeName)
//        break;
//      case 4:
//        Navigator.of(context).pushAndRemoveUntil(newRoute, predicate)
//        break;
//      case 5:
//        Navigator.of(context).pushNamedAndRemoveUntil(newRouteName, predicate)
//        break;
//      case 6:
//        Navigator.of(context).popAndPushNamed(routeName)
//        break;
      }
    });
  }
}
